<style lang="less" scoped>
  .topbar{
    display: flex;
    height: 92px;
    align-items: center;
    padding-right: 21px;
    text-align: center;
    background: #000;
    color: #fff;
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index:99;
    div{
      flex: 1;
      .logo{
        width: 130px;
      }
    }
    .backico{
      text-align: left;
      .back-box{
        padding: 0 15px 0 29px;
        background: url(../assets/images/back.png) no-repeat;
        background-size: 50px 50px;
        width: 42px;
        height: 42px;
        background-position: center;
      }
    }
    .title{
      font-size: 32px;
      font-weight: 400;
      color: #FFFFFF;
    }
  }
  .usermsg{
    display: flex;
    align-items: center;
    text-align: right;
    .uphone{
      font-size: 22px;
      color: #939CAB
    }
    .umoney{
      font-size: 24px;
      color: #FFA22A
    }
    img{
      width: 67px;
      margin: 0 15px 0 18px;
    }
  }
</style>

<template>
  <div class="topbar">
    <div class="backico">
      <div class="back-box" @click="$router.go(-1)"></div>
    </div>
    <div>
      <p class="title" v-if="title">{{title}}</p>
      <img v-else class="logo" src="../assets/images/logo.png" alt="">
    </div>
    <div>
      <div class="usermsg" v-if="store.state.token">
        <div>
          <p class="uphone">{{store.state.userMsg.mobile}}</p>
          <p class="umoney">{{store.state.userMsg.money}}</p>
        </div>
        <img @click="openUser" :src="store.state.userMsg.photo" alt="">
      </div>
      <slot v-else></slot>
    </div>
  </div>  
</template>

<script>
import { useStore } from "vuex"
import { useRouter, useRoute } from 'vue-router'
import { inject } from "vue"
export default {
  setup() {
    let title = inject('title')
    const store = useStore()
    const router = useRouter()
    const openUser = () => {
      router.push('/User')
    }
    const route = useRoute()
    return {
      route,
      store,
      openUser,
      title
    }
  }
}
</script>